﻿<?php require_once('../Connections/hitekforyou.php'); ?>
<?php
require_once('checklogin.php');
error_reporting(0);
// Load the common classes
require_once('../includes/common/KT_common.php');

// Load the tNG classes
require_once('../includes/tng/tNG.inc.php');

// Load the required classes
require_once('../includes/tfi/TFI.php');
require_once('../includes/tso/TSO.php');
require_once('../includes/nav/NAV.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("../");

// Make unified connection variable
$conn_hitekforyou = new KT_connection($hitekforyou, $database_hitekforyou);



if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

// Filter
$tfi_listchitietsp1 = new TFI_TableFilter($conn_hitekforyou, "tfi_listchitietsp1");
$tfi_listchitietsp1->addColumn("chitietsp.idChitietSP", "NUMERIC_TYPE", "idChitietSP", "=");
$tfi_listchitietsp1->addColumn("sanpham.idSP", "NUMERIC_TYPE", "idSP", "=");
$tfi_listchitietsp1->addColumn("chitietsp.Chipset", "STRING_TYPE", "Chipset", "%");
$tfi_listchitietsp1->addColumn("chitietsp.CPU", "STRING_TYPE", "CPU", "%");
$tfi_listchitietsp1->addColumn("chitietsp.Ram", "STRING_TYPE", "Ram", "%");
$tfi_listchitietsp1->Execute();

// Sorter
$tso_listchitietsp1 = new TSO_TableSorter("rschitietsp1", "tso_listchitietsp1");
$tso_listchitietsp1->addColumn("chitietsp.idChitietSP");
$tso_listchitietsp1->addColumn("sanpham.idSP");
$tso_listchitietsp1->addColumn("chitietsp.Chipset");
$tso_listchitietsp1->addColumn("chitietsp.CPU");
$tso_listchitietsp1->addColumn("chitietsp.Ram");
$tso_listchitietsp1->setDefault("chitietsp.idChitietSP");
$tso_listchitietsp1->Execute();

// Navigation
$nav_listchitietsp1 = new NAV_Regular("nav_listchitietsp1", "rschitietsp1", "../", $_SERVER['PHP_SELF'], 10);

mysql_select_db($database_hitekforyou, $hitekforyou);
$query_Recordset1 = "SELECT idSP, idSP FROM sanpham ORDER BY idSP";
$Recordset1 = mysql_query($query_Recordset1, $hitekforyou) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

//NeXTenesio3 Special List Recordset
$maxRows_rschitietsp1 = $_SESSION['max_rows_nav_listchitietsp1'];
$pageNum_rschitietsp1 = 0;
if (isset($_GET['pageNum_rschitietsp1'])) {
  $pageNum_rschitietsp1 = $_GET['pageNum_rschitietsp1'];
}
$startRow_rschitietsp1 = $pageNum_rschitietsp1 * $maxRows_rschitietsp1;

// Defining List Recordset variable
$NXTFilter_rschitietsp1 = "1=1";
if (isset($_SESSION['filter_tfi_listchitietsp1'])) {
  $NXTFilter_rschitietsp1 = $_SESSION['filter_tfi_listchitietsp1'];
}
// Defining List Recordset variable
$NXTSort_rschitietsp1 = "chitietsp.idChitietSP";
if (isset($_SESSION['sorter_tso_listchitietsp1'])) {
  $NXTSort_rschitietsp1 = $_SESSION['sorter_tso_listchitietsp1'];
}
mysql_select_db($database_hitekforyou, $hitekforyou);

$query_rschitietsp1 = "SELECT chitietsp.idChitietSP, sanpham.idSP AS idSP, chitietsp.Chipset, chitietsp.CPU, chitietsp.Ram FROM chitietsp LEFT JOIN sanpham ON chitietsp.idSP = sanpham.idSP WHERE {$NXTFilter_rschitietsp1} ORDER BY {$NXTSort_rschitietsp1}";
$query_limit_rschitietsp1 = sprintf("%s LIMIT %d, %d", $query_rschitietsp1, $startRow_rschitietsp1, $maxRows_rschitietsp1);
$rschitietsp1 = mysql_query($query_limit_rschitietsp1, $hitekforyou) or die(mysql_error());
$row_rschitietsp1 = mysql_fetch_assoc($rschitietsp1);

if (isset($_GET['totalRows_rschitietsp1'])) {
  $totalRows_rschitietsp1 = $_GET['totalRows_rschitietsp1'];
} else {
  $all_rschitietsp1 = mysql_query($query_rschitietsp1);
  $totalRows_rschitietsp1 = mysql_num_rows($all_rschitietsp1);
}
$totalPages_rschitietsp1 = ceil($totalRows_rschitietsp1/$maxRows_rschitietsp1)-1;
//End NeXTenesio3 Special List Recordset

// Make a logout transaction instance
$logoutTransaction = new tNG_logoutTransaction($conn_hitekforyou);
$tNGs->addTransaction($logoutTransaction);
// Register triggers
$logoutTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "GET", "KT_logout_now");
$logoutTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "login.php");
// Add columns
// End of logout transaction instance

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);

$nav_listchitietsp1->checkBoundries();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="quantri.css" rel="stylesheet" type="text/css" />
<script src="../AC_RunActiveContent.js" type="text/javascript"></script>

<title>Quản trị web HitekForYou</title>
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script><script src="../includes/nxt/scripts/list.js" type="text/javascript"></script><script src="../includes/nxt/scripts/list.js.php" type="text/javascript"></script><script type="text/javascript">
$NXT_LIST_SETTINGS = {
  duplicate_buttons: true,
  duplicate_navigation: true,
  row_effects: true,
  show_as_buttons: true,
  record_counter: true
}
</script><style type="text/css">
  /* Dynamic List row settings */
  .KT_col_idChitietSP {
	width:80px;
	overflow:hidden;
}
  .KT_col_idSP {
	width:100px;
	overflow:hidden;
}
  .KT_col_Chipset {
	width:80px;
	overflow:hidden;
}
  .KT_col_CPU {
	width:80px;
	overflow:hidden;
}
  .KT_col_Ram {
	width:80px;
	overflow:hidden;
}
</style>

</head>

<body>

<?php include("admin_template/header.php"); ?>
<?php include("admin_template/admin_banner.php"); ?>  
<table id="main" width="990" border="1" align="center" cellpadding="0" cellspacing="0">
 <tr>
    <td width="200" align="left" valign="top" bgcolor="#66CC00" id="cottrai">
      <div align="left">
      <?php include("menu.php"); ?>  
      </div>       </td>
    <td id="cotphai" width="790" align="left" valign="top" bgcolor="#CCFF00">
  
   
<div class="KT_tng" id="listchitietsp1">
  <h1> Danh sách chi tiết sản phẩm
    <?php
  $nav_listchitietsp1->Prepare();
  require("../includes/nav/NAV_Text_Statistics.inc.php");
?>
  </h1>
  <div class="KT_tnglist">
    <form action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>" method="post" id="form1">
      <div class="KT_options"> <a href="<?php echo $nav_listchitietsp1->getShowAllLink(); ?>">Hiện
            <?php 
  // Show IF Conditional region1
  if (@$_GET['show_all_nav_listchitietsp1'] == 1) {
?>
            <?php echo $_SESSION['default_max_rows_nav_listchitietsp1']; ?>
            <?php 
  // else Conditional region1
  } else { ?>
            tất cả
            <?php } 
  // endif Conditional region1
?>
            dữ liệu</a> &nbsp;
        &nbsp;
                            <?php 
  // Show IF Conditional region2
  if (@$_SESSION['has_filter_tfi_listchitietsp1'] == 1) {
?>
                            <a href="<?php echo $tfi_listchitietsp1->getResetFilterLink(); ?>">Đóng bộ lọc</a>
                            <?php 
  // else Conditional region2
  } else { ?>
                            <a href="<?php echo $tfi_listchitietsp1->getShowFilterLink(); ?>">Hiện bộ lọc</a>
                            <?php } 
  // endif Conditional region2
?>
      </div>
      <table cellpadding="2" cellspacing="0" class="KT_tngtable">
        <thead>
          <tr class="KT_row_order">
            <th> <input type="checkbox" name="KT_selAll" id="KT_selAll"/>
            </th>
            <th id="idChitietSP" class="KT_sorter KT_col_idChitietSP <?php echo $tso_listchitietsp1->getSortIcon('chitietsp.idChitietSP'); ?>"> <a href="<?php echo $tso_listchitietsp1->getSortLink('chitietsp.idChitietSP'); ?>">ID Chi tiết</a> </th>
            <th id="idSP" class="KT_sorter KT_col_idSP <?php echo $tso_listchitietsp1->getSortIcon('sanpham.idSP'); ?>"> <a href="<?php echo $tso_listchitietsp1->getSortLink('sanpham.idSP'); ?>">ID Sản phẩm</a> </th>
            <th id="Chipset" class="KT_sorter KT_col_Chipset <?php echo $tso_listchitietsp1->getSortIcon('chitietsp.Chipset'); ?>"> <a href="<?php echo $tso_listchitietsp1->getSortLink('chitietsp.Chipset'); ?>">Chip</a> </th>
            <th id="CPU" class="KT_sorter KT_col_CPU <?php echo $tso_listchitietsp1->getSortIcon('chitietsp.CPU'); ?>"> <a href="<?php echo $tso_listchitietsp1->getSortLink('chitietsp.CPU'); ?>">CPU</a> </th>
            <th id="Ram" class="KT_sorter KT_col_Ram <?php echo $tso_listchitietsp1->getSortIcon('chitietsp.Ram'); ?>"> <a href="<?php echo $tso_listchitietsp1->getSortLink('chitietsp.Ram'); ?>">Ram</a> </th>
            <th>&nbsp;</th>
          </tr>
          <?php 
  // Show IF Conditional region3
  if (@$_SESSION['has_filter_tfi_listchitietsp1'] == 1) {
?>
          <tr class="KT_row_filter">
            <td>&nbsp;</td>
            <td><input type="text" name="tfi_listchitietsp1_idChitietSP" id="tfi_listchitietsp1_idChitietSP" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listchitietsp1_idChitietSP']); ?>" size="10" maxlength="100" /></td>
            <td><select name="tfi_listchitietsp1_idSP" id="tfi_listchitietsp1_idSP">
              <option value="" <?php if (!(strcmp("", @$_SESSION['tfi_listchitietsp1_idSP']))) {echo "SELECTED";} ?>><?php echo NXT_getResource("None"); ?></option>
              <?php
do {  
?>
              <option value="<?php echo $row_Recordset1['idSP']?>"<?php if (!(strcmp($row_Recordset1['idSP'], @$_SESSION['tfi_listchitietsp1_idSP']))) {echo "SELECTED";} ?>><?php echo $row_Recordset1['idSP']?></option>
              <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
            </select>
            </td>
            <td><input type="text" name="tfi_listchitietsp1_Chipset" id="tfi_listchitietsp1_Chipset" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listchitietsp1_Chipset']); ?>" size="12" maxlength="255" /></td>
            <td><input type="text" name="tfi_listchitietsp1_CPU" id="tfi_listchitietsp1_CPU" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listchitietsp1_CPU']); ?>" size="20" maxlength="255" /></td>
            <td><input type="text" name="tfi_listchitietsp1_Ram" id="tfi_listchitietsp1_Ram" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listchitietsp1_Ram']); ?>" size="12" maxlength="50" /></td>
            <td><input type="submit" name="tfi_listchitietsp1" value="Lọc" /></td>
          </tr>
          <?php } 
  // endif Conditional region3
?>
        </thead>
        <tbody>
          <?php if ($totalRows_rschitietsp1 == 0) { // Show if recordset empty ?>
          <tr>
            <td colspan="7"><?php echo NXT_getResource("Dữ liệu đang rỗng hoặc từ khóa lọc của bạn quá dài."); ?></td>
          </tr>
          <?php } // Show if recordset empty ?>
          <?php if ($totalRows_rschitietsp1 > 0) { // Show if recordset not empty ?>
          <?php do { ?>
          <tr class="<?php echo @$cnt1++%2==0 ? "" : "KT_even"; ?>">
            <td><input type="checkbox" name="kt_pk_chitietsp" class="id_checkbox" value="<?php echo $row_rschitietsp1['idChitietSP']; ?>" />
                <input type="hidden" name="idChitietSP" class="id_field" value="<?php echo $row_rschitietsp1['idChitietSP']; ?>" />
            </td>
            <td><div class="KT_col_idChitietSP"><?php echo KT_FormatForList($row_rschitietsp1['idChitietSP'], 20); ?></div></td>
            <td><div class="KT_col_idSP"><?php echo KT_FormatForList($row_rschitietsp1['idSP'], 20); ?></div></td>
            <td><div class="KT_col_Chipset"><?php echo KT_FormatForList($row_rschitietsp1['Chipset'], 20); ?></div></td>
            <td><div class="KT_col_CPU"><?php echo KT_FormatForList($row_rschitietsp1['CPU'], 20); ?></div></td>
            <td><div class="KT_col_Ram"><?php echo KT_FormatForList($row_rschitietsp1['Ram'], 20); ?></div></td>
            <td><a class="KT_edit_link" href="FormChiTietSP.php?idChitietSP=<?php echo $row_rschitietsp1['idChitietSP']; ?>&amp;KT_back=1">Sửa</a> <a class="KT_delete_link" href="#delete">Xóa</a> </td>
          </tr>
          <?php } while ($row_rschitietsp1 = mysql_fetch_assoc($rschitietsp1)); ?>
          <?php } // Show if recordset not empty ?>
        </tbody>
      </table>
      <div class="KT_bottomnav">
        <div>
          <?php
            $nav_listchitietsp1->Prepare();
            require("../includes/nav/NAV_Text_Navigation.inc.php");
          ?>
        </div>
      </div>
      <div class="KT_bottombuttons">
        <div class="KT_operations"> </a> <a class="KT_delete_op_link" href="#" onclick="nxt_list_delete_link_form(this); return false;">Xóa nhiều</a> </div>
        <span>&nbsp;</span>
       
        <a class="KT_additem_op_link" href="FormChiTietSP.php?KT_back=1" onclick="return nxt_list_additem(this)">Thêm</a> </div>
    </form>
  </div>
  <br class="clearfixplain" />
</div>
<p>&nbsp;</p>
</tr>
</table>
<?php include("admin_template/footer.php"); ?>  
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($rschitietsp1);
?>

